#include <gtk/gtk.h>

GtkWidget *window;
GtkWidget *label;
GdkPixbuf *icon;

int full_screen = 0;

static gboolean full_screen_callback (GtkWidget *widget,
        GdkEvent  *event,
        gpointer   data)
{
    if (full_screen == 0) {
        gtk_window_fullscreen(GTK_WINDOW(window));
        full_screen = 1;
    } else {
        full_screen = 0;
        gtk_window_unfullscreen(GTK_WINDOW(window));
    }
    
    return TRUE;
}

int main(int argc, char *argv[]) {
    gtk_init(&argc, &argv);

    g_set_prgname("gtkapp");
    window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
    gtk_window_set_title(GTK_WINDOW(window), "gtkapp");
    gtk_window_set_default_size(GTK_WINDOW(window), 200, 100);
    gtk_container_set_border_width(GTK_CONTAINER(window), 10);
    gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER);

    label = gtk_label_new("Hello World!");
    gtk_container_add(GTK_CONTAINER(window), label);
    // gtk_header_bar_set_title("windows");

    // CSD
    GtkWidget *header = gtk_header_bar_new();
    // 设置标题
    GtkWidget *label = gtk_label_new("Title");
    gtk_label_set_markup(GTK_LABEL(label), "<span font_desc='12.5' weight='normal'>Title</span>");
    gtk_header_bar_set_custom_title(GTK_HEADER_BAR(header), GTK_LABEL(label));
    // 设置最大最小化按钮
    gtk_header_bar_set_show_close_button(GTK_WIDGET(header),TRUE);
    gtk_header_bar_set_decoration_layout(GTK_HEADER_BAR(header),"menu:minimize,maximize,close");
    gtk_window_set_titlebar(GTK_WINDOW(window), header);

    // 设置默认图标
    gtk_window_set_icon_name(GTK_WINDOW(window), "desktopappengine");

    GtkWidget *button;
    button = gtk_button_new_with_label ("Full screen");
    g_signal_connect (button, "clicked", G_CALLBACK (full_screen_callback), NULL);
    gtk_container_add(GTK_CONTAINER(window), button);

    gtk_widget_show_all(window);
    gtk_main();

    return 0;
}

